// 导入用户集合
const { Article } = require('../../../model/article');
// 引入分页模块
const pagination = require('mongoose-sex-page')

module.exports = async (req, res) => {
  const { pageIndex, pageSize, state } = req.query
  const articles = await pagination(Article).find({
    state
  }).sort({_id: -1}).page(pageIndex).size(pageSize).populate('category author').exec()
  res.json({
      data: articles
  })
}